#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：V2 
@File    ：run_maze.py
@IDE     ：PyCharm 
@Author  ：郭星
@Date    ：2025/9/9 21:56 
'''
from maze_env import Maze
from RL_brain import QLearningTable
def update():
    for episode in range(100):
        obsercation = env.reset()
        while True:
            env.render()
            action = RL.choose_action(obsercation)
            obsercation_, reward, done = env.step(action)
            RL.learn(str(obsercation), action, reward, obsercation_)
            # RL.store_transition(obsercation, action, reward, obsercation_)
            obsercation = obsercation_
            if done:
                break
    print('game over')
    env.destroy()

if __name__ == '__main__':
    env = Maze()
    RL = QLearningTable(actions=list(range(env.n_actions)))
    env.after(100, update)
    env.mainloop()